import requests
import json

def dingmessage(tex):
# 请求的URL，WebHook地址
    webhook = "https://oapi.dingtalk.com/robot/send?access_token=fc602653266734564af2d1c6706e0f347354d504512ea23fff9d2c819fe323d6"
# 构建请求头部
    header = {
        "Content-Type": "application/json",
        "Charset": "UTF-8"
}
# 构建请求数据
    tex = tex
    message ={

        "msgtype": "text",
        "text": {
            "content": tex
        },
        "at": {

            "isAtAll": True
        }

    }
# 对请求的数据进行json封装
    message_json = json.dumps(message)
# 发送请求
    info = requests.post(url=webhook, data=message_json, headers=header)
# 打印返回的结果
    print(info.text)

# if __name__=="__main__":
#     dingmessage()